#include <iostream>
using namespace std;

char board[3][3] = {{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}};
int current_player = 1; // 假设玩家1使用字符X，玩家2使用O

void drawBoard() {
    cout << "  0   1   2\n";
    for (int i = 0; i < 3; ++i){
        cout << i;
        for(int j = 0; j < 3; ++j)
            cout << " | " << board[i][j];
        cout << endl;
        if(i != 2) 
            cout << " ---|---|---\n";
    }
}

bool checkWin(char symbol) {
    return ((board[0][0] == symbol && board[0][1] == symbol && board[0][2] == symbol) ||
            (board[1][0] == symbol && board[1][1] == symbol && board[1][2] == symbol) ||
            (board[2][0] == symbol && board[2][1] == symbol && board[2][2] == symbol) ||
            (board[0][0] == symbol && board[1][0] == symbol && board[2][0] == symbol) ||
            (board[0][1] == symbol && board[1][1] == symbol && board[2][1] == symbol) ||
            (board[0][2] == symbol && board[1][2] == symbol && board[2][2] == symbol) ||
            (board[0][0] == symbol && board[1][1] == symbol && board[2][2] == symbol) ||
            (board[0][2] == symbol && board[1][1] == symbol && board[2][0] == symbol));
}

void playMove(int row, int col) {
    if(board[row][col] == ' ') { // 判断当前位置是否为空
        char mark = (current_player == 1)? 'X':'O';
        board[row][col] = mark;
        
        bool won = checkWin(mark);
        if(won) {
            cout << "\nPlayer " << current_player << " wins!\n";
            exit(0); // 游戏结束退出程序
        }

        current_player = (current_player == 1) ? 2 : 1; // 更换下一位玩家
    } else {
        cout << "\nThis position is occupied.\nPlease try another one.";
    }
}